package com.github.admin.edu.security.jwt.server.domain;

import com.github.admin.edu.orm.repository.CustomRepository;
import com.github.admin.edu.security.jwt.server.entity.TSysOrginzation;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * Create by IntelliJ IDEA
 * 用户：王建
 * 日期：2018-8-1
 */
public interface ServerOrganizationDomain extends CustomRepository<TSysOrginzation,Integer> {

    @Query("select t from TSysOrginzation t order by t.ordernum asc ")
    List<TSysOrginzation> getAll();

    @Modifying
    @Query("delete from TSysOrginzation t where t.treeCode like :treeCode")
    void deleteAllByTreeCode(@Param("treeCode")String code);

    @Query("select t from TSysOrginzation t where t.parentid = -1 order by t.ordernum asc ")
    List<TSysOrginzation> getByFirstRoot();

}
